#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void MonthDay(int year, int yearDay, int* pMonth, int* pDay);
int IsLeapYear(int y);
int main(void)
{
	int year, month, day, yearDay, n;
	do {
		printf("Input year,yearDay:");
		n = scanf("%d,%d", &year, &yearDay);
		if (n != 2)while (getchar() != '\n');

	} while (n != 2 || year < 0 || yearDay < 1 || yearDay>366);
	MonthDay(year, yearDay, &month, &day);
	printf("month=%d,day=%d\n", month, day);
	return 0;
}
void MonthDay(int year, int yearDay, int* pMonth, int* pDay)
{
	int dayofmonth[2][12] = { {31,28,31,30,31,30,31,31,30,31,30,31},
	 {31,29,31,30,31,30,31,31,30,31,30,31} };
	int i, leap;
	leap = IsLeapYear(year);
	for (i = 1; yearDay > dayofmonth[leap][i - 1]; i++)
	{
		yearDay = yearDay - dayofmonth[leap][i - 1];
	}
	*pMonth = i;
	*pDay = yearDay;
}
int IsLeapYear(int y)
{
	return((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) ? 1 : 0;
}
